package com.yincheng.oes.business.util;

import com.yincheng.oes.attachment.entity.Attachment;
import com.yincheng.oes.sso.util.UserUtils;

import java.util.Date;

/**
 * @Description TODO
 * @Author 446948434@qq.com
 * @Date 2021/10/28 9:58 下午
 * @Version 1.0
 */
public class AttachmentUtils {
    private static final String TMP_ROOT_KEY = "temp_path";

    public static Attachment getAttachment(String fileName, long fileSize, String fileTYpe,String userId){
        Attachment attachment = new Attachment();
        attachment.setAttachmentId(StringUtil.generateUUID());
        attachment.setDownloadUrl(TimeUtils.getYYMMdd() + "/" + fileName);
        attachment.setFileName(fileName);
        attachment.setFileSize(fileSize);
        attachment.setFileType(fileTYpe);
        attachment.setStoreTime(new Date());
        attachment.setRootKey(TMP_ROOT_KEY);
        attachment.setOperatorId(userId);
        return attachment;
    }

    public static Attachment getAttachment(String fileName, long fileSize, String fileTYpe){
       return getAttachment(fileName,fileSize,fileTYpe,UserUtils.getUser().getUserId());
    }
}
